<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Staticpageadm extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 */
	public function index(){
		$this->mng_kontenstatis();
	}

//------------------------------------------------------------------------------------------->konten statis{
function mng_kontenstatis($mode=""){
		if($mode=="error"){
			$pesan="Kesalahan, field pada form berita harus diisi";
		}elseif($mode=="update"){
			$pesan="Konten Statis berhasil diperbaharui";
		}elseif($mode=="delete"){
			$pesan="Data konten statis berhasil dihapus";
		}else{
			$pesan="";	
		}
			$this->load->library('pagination');
			$this->load->model('tbl_kontenstatis');
			$banyak = $this->tbl_kontenstatis->hitung();
			$base_url = base_url();
			$config['base_url'] = $base_url.'paneladm/staticpageadm/';
			$config['total_rows'] = $banyak;
			$config['per_page'] = '15'; 
			$this->pagination->initialize($config);
		$data['mode']  = $mode;
		$data['pesan'] = $pesan;	
		$data['jumlah'] =$banyak;
		$data['query']= $this->tbl_kontenstatis->load();
		$this->load->view('admin/staticpageadm/admin-mng-kotenstatis',$data);
    }

	function view_kontenstatis($id){
		$this->load->model('tbl_kontenstatis');
		$data['query'] = $this->tbl_kontenstatis->edit($id);	
        $this->load->view('admin/staticpageadm/admin-view-kontenstatis', $data);
	}
	
	function edit_kontenstatis($id) {
		$this->load->plugin('xinha');
		$data['xinha_inclusion'] = javascript_xinha(array('teks'), 
	                                               array('InsertPicture',
												         'InsertPagebreak',
														 'Template',
														 'CharacterMap',
														 'ImageManager',
														 'ListType',
														 'SuperClean',
														 'TableOperations',
														 'FindReplace',
														 'HorizontalRule'), 
												   "default");
	    $this->load->model('tbl_kontenstatis');
		$data['query'] = $this->tbl_kontenstatis->edit($id);	
        $this->load->view('admin/staticpageadm/admin-edit-kontenstatis', $data);
    }
	
	function update_kontenstatis(){
		$id			= mySQL_escape_string($this->input->post('id'));
		$isi	 	= mySQL_escape_string($this->input->post('kontenstatis_isi'));
		$tanggal	= date("Y-m-d H:i:s");
		if(empty($isi)){
			redirect('paneladm/staticpageadm/mng_kontenstatis/error');
		}
		$this->load->model('tbl_kontenstatis');
		$this->tbl_kontenstatis->update($id, $isi, $tanggal);	
        redirect('paneladm/staticpageadm/mng_kontenstatis/update'); 
	}
//------------------------------------------------------------------------------------------->konten statis}
}